// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
//Event.observe(window, 'load', function() {
//  Event.observe('turnon', 'click', function(event) { $('logininfo').hide(); $('loginform').show(); $('login').focus(); });   
//  Event.observe($('input'), 'mouseover', function(event) {Element.event(event).focus();})
//});

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    return [curleft,curtop];
}

var last;
Effect.DefaultOptions.duration = 0.25;
Event.addBehavior({
  '#turnon:click':     function() { $('logininfo').hide(); $('loginform').show(); $('login').focus(); },
  
  'input:mouseover':  function() { this.select();},
  'textarea:mouseover':  function() { this.select();},
  'div.flow:click':  function() { if (last) last.hide();},
  'img.friendicon:mouseover': function(e) {
      if (last) last.hide();
      img = $(this.id)
      var thediv = $('capped' + this.id);  
      if (thediv) {               
        pos = findPos(this);
        thediv.style.position = 'absolute';
        thediv.style.zIndex = "3";
        thediv.style.top = (pos[1]+44) +'px';
        thediv.style.left = (pos[0]+44) + 'px';
        thediv.show();
        last=thediv;
      }
  }

//  'a.theme_dialog:click': function() {
//    var img = this.down('img');
//    var pieces = img.src.split('/');
//    new Dialog.Rjs();
//    new Ajax.Request(Mephisto.root + '/admin/themes/show/' + pieces[pieces.length-1]);
//  }
  
});

Event.onReady(function() {
  Nifty("div#friend,div#family,div#adbar,div#box", "top right transparent");
  Nifty("div#menu","bottom transparent")
//  ['notice', 'errors'].each(function(flashType) {
//    var el = $('flash-' + flashType);
//    if(el.innerHTML != '') Flash.show(flashType, el.innerHTML);
//  })
  
});

